package main

import (
	"fmt"
	"os"
)

func main() {
	// 绝对路径
	path := "D:/code/me/go/git/src/study-go/goyykfsz/ch09/picture/test.png"
	printMessage(path)
	// 相对路径
	path = "./goyykfsz/ch09/picture/test.png"
	printMessage(path)
}

func printMessage(filePath string) {
	fileInfo, err := os.Stat(filePath)
	if err != nil {
		fmt.Println("err:", err.Error())
		return
	}

	fmt.Printf("数据类型是：%T \n", fileInfo)
	fmt.Printf("文件名：%s\n", fileInfo.Name())
	fmt.Printf("是否为目录：%v\n", fileInfo.IsDir())
	fmt.Printf("文件大小：%v\n", fileInfo.Size())
	fmt.Printf("文件权限：%v\n", fileInfo.Mode())
	fmt.Printf("文件最后修改时间：%v\n", fileInfo.ModTime())
}
